package com.wq;

/**
 * @Author: wangqiang20995
 * @Date:2019/1/25
 * @Description:
 * @Resource:
 */
public class Demo {
    public static void main(String args[]) {
        for (int i = 0; i < 10; i++) {
            new B();
            System.out.println("---------------------------");
        }

        String subfix = "0679241903281234568XXX";
//        String subfix = "06792420190328123456XX";
        boolean newRule = subfix.contains("XXX");
        subfix = analyseSerial(subfix.substring(6), newRule);
        System.out.println(subfix);
    }

    public static String analyseSerial(String thirdSerial, boolean newRule) {
        if (!newRule) {
            String regex = "^\\d{15}X$";
            if (thirdSerial.matches(regex)) {
                return thirdSerial.substring(0, 15);
            } else {
                return thirdSerial.substring(0, 14);
            }
        } else {
            String regex = "^\\d{13}XXX$";//流水号中最后的X由1/2-->3/4，所以数字的位数相对应的变成13/12位
            if (thirdSerial.matches(regex)) {
                return "20" + thirdSerial.substring(0, 13);
            } else {
                return "20" + thirdSerial.substring(0, 12);
            }
        }

    }
}

class A {

    static {
        System.out.println("as");
    }

    {
        System.out.println("ad");
    }

    public A() {
        System.out.println("ac");
    }
}

class B extends A {
    static {
        System.out.println("bs");
    }

    {
        System.out.println("bd");
    }

    public B() {
        System.out.println("bc");
    }
}
